package tasks.OpportunitiesBaseData.MainView;
import java.sql.SQLException;
import java.util.ArrayList;

import resources.tasks.OpportunitiesBaseData.MainView.STGDBWrapperHelper;
import tasks.OpportunitiesBaseData.ContentRule;
import tasks.OpportunitiesBaseData.Pattern;


import dbops.SQLOperator;
/**
 * Description   : Functional Test Script
 * @author angel.tsvetkov
 */
public class STGDBWrapper extends STGDBWrapperHelper
{
	/**
	 * Script Name   : <b>DBWrapper</b>
	 * Generated     : <b>Nov 24, 2011 5:02:03 PM</b>
	 * Description   : Functional Test Script
	 * Original Host : WinNT Version 6.1  Build 7601 (S)
	 * 
	 * @since  2011/11/24
	 * @author angel.tsvetkov
	 */
	
	public STGLayout get(String detailNumber)
	{
		STGLayout layout = new STGLayout();
		
		ContentRule rule = new ContentRule("MainView\\STGMainView.sql");
		SQLOperator query = new SQLOperator();
		
		ArrayList<ArrayList<String>> dbContentTmp = new ArrayList<ArrayList<String>>();
		try {
			dbContentTmp = query.executeSelect(rule.getRule(new Pattern("%OPP_DTL_KEY%",detailNumber)));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		ArrayList<String> row = dbContentTmp.get(0);


		layout.setRepInput(row.get(STGColumns.RepInput.ordinal()));

		layout.setGeo(row.get(STGColumns.Geo.ordinal()));

		layout.setImt(row.get(STGColumns.IMT.ordinal()));

		layout.setSeller(row.get(STGColumns.Seller.ordinal()));

		layout.setInsideSalesInv(row.get(STGColumns.InsideSalesInv.ordinal()));

		layout.setOwner(row.get(STGColumns.Owner.ordinal()));

		layout.setQtrInd(row.get(STGColumns.QtrInd.ordinal()));

		layout.setDecWkorFcstWk(row.get(STGColumns.DecWkorFcstWk.ordinal()));

		layout.setFcstDate(row.get(STGColumns.FcstDate.ordinal()));

		layout.setSubbrand(row.get(STGColumns.Subbrand.ordinal()));

		layout.setProdlvl30(row.get(STGColumns.ProdLvl30.ordinal()));

		layout.setOppNo(row.get(STGColumns.OppNo.ordinal()));

		layout.setDtlKey(row.get(STGColumns.DtlKey.ordinal()));

		layout.setCustName(row.get(STGColumns.CustName.ordinal()));

		layout.setCustNo(row.get(STGColumns.CustNo.ordinal()));

		layout.setOwnOrg(row.get(STGColumns.OwnOrg.ordinal()));

		layout.setOppSource(row.get(STGColumns.OppSource.ordinal()));

		layout.setOppName(row.get(STGColumns.OppName.ordinal()));

		layout.setSsCode(row.get(STGColumns.SSCode.ordinal()));

		layout.setSsName(row.get(STGColumns.SSName.ordinal()));

		layout.setDtlOdds(row.get(STGColumns.DtlOdds.ordinal()));

		layout.setDtlRev(row.get(STGColumns.DtlRev.ordinal()));

		layout.setPrismRev(row.get(STGColumns.PrismRev.ordinal()));

		layout.setIbssRev(row.get(STGColumns.IBSSRev.ordinal()));

		layout.setOppRole(row.get(STGColumns.OppRole.ordinal()));

		layout.setSiebelPVStatus(row.get(STGColumns.SiebelPVStatus.ordinal()));

		layout.setPrismPVStatus(row.get(STGColumns.PRISMPVStatus.ordinal()));

		return layout;
	}
}

